//
//  ProgressHUD+Custom.m
//  QMCXDriver
//
//  Created by Massimo on 2017/4/15.
//  Copyright © 2017年 Massimo. All rights reserved.
//

#import "ProgressHUD+Custom.h"
#import "ObjcRuntime.h"
@implementation ProgressHUD (Custom)
+ (void)load{
    
    SEL origSel = NSSelectorFromString(@"shared");
    SEL newSel = NSSelectorFromString(@"swizzleShared");
    Method newMethod = class_getClassMethod([self class], newSel);
    Method origMethod = class_getClassMethod([self class], origSel);
    method_exchangeImplementations(origMethod, newMethod);
}

+ (ProgressHUD *)swizzleShared{
    
    static dispatch_once_t once = 0;
    static ProgressHUD *progressHUD;
    //---------------------------------------------------------------------------------------------------------------------------------------------
    dispatch_once(&once, ^{
        progressHUD = [[ProgressHUD alloc] init];
    });
    //---------------------------------------------------------------------------------------------------------------------------------------------
    if (progressHUD.spinner == nil)
    {
        progressHUD.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
        progressHUD.spinner.color = Q_SPINNER_COLOR;
        progressHUD.spinner.hidesWhenStopped = YES;
      
    }
    
    if (progressHUD.hud == nil) {
        progressHUD.hud = [[UIToolbar alloc] initWithFrame:CGRectZero];
        progressHUD.hud.translucent = YES;
        progressHUD.hud.backgroundColor = LLColorRGBA(50, 52, 61,0.8);
        progressHUD.hud.layer.cornerRadius = 10;
        progressHUD.hud.layer.masksToBounds = YES;
    }
    
    return progressHUD;
    
}

@end
